Fix translation of string message content#5
Open
tristanmanchester wants to merge 1 commit intoopenai:mainfrom
Open
Fix translation of string message content#5tristanmanchester wants to merge 1 commit intoopenai:mainfrom
tristanmanchester wants to merge 1 commit intoopenai:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
{ text: ... }before it enters the translation pipeline.translatedMessageswith the normalized translatable message so async translation responses update the translated clone.@ts-ignoreby constructing theTranslatableMessagethrough explicit text/developer branches.Bug
Message.contentcan be either an array of content objects or a plain string. The translation queue previously usedmessage.content[0]for every text/developer message. For plain strings, that indexes the first character, so"Hello"became"H"instead of a text content object.That malformed shape meant translation requests were built from the wrong content and downstream logic expected object fields such as
texton a string character.Fix
The translation queue now calls the existing
getContentFromContentOrStringhelper, which converts string content into{ text: fullString }and preserves array-backed content by selecting the first content object. The normalized message is assigned back intotranslatedMessages[i]before translation starts, ensuring response handling mutates the translated clone rather than a temporary object.Verification
message.content[0]expression is no longer used in the translation queue.pnpm run buildsuccessfully.